﻿using System.Reflection;
using NLite.Internal;
using System;
using NLite.Collections;

namespace NLite.Reflection
{


    /// <summary>
    /// 
    /// </summary>
    public static class SetterExtensions
    {
        private static readonly IMap<MemberInfo, Setter> setterCache = new Map<MemberInfo, Setter>();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="member"></param>
        /// <param name="target"></param>
        /// <param name="value"></param>
        public static void Set(this MemberInfo member, object target, object value)
        {
            setterCache.GetOrAdd(member, () => member.GetSetter())(target, value);
        }
    }
}
